<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
             label-width="68px"
    >
      <el-form-item label="应用信息" prop="app_id">
        <el-select
          v-model="queryParams.app_id"
          placeholder="请选择应用信息"
        >
          <el-option
            v-for="item in appOptions"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="类型" prop="type">
        <el-select
          v-model="queryParams.type"
          placeholder="类型"
          clearable
          style="width: 240px"
        >
          <el-option
            v-for="dict in dict.type.app_activity_type"
            :key="dict.value"
            :label="dict.label"
            :value="parseInt(dict.value)"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="标题" prop="title">
        <el-input
          v-model="queryParams.title"
          placeholder="请输入标题"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="语言" prop="lang">
        <el-select
          v-model="queryParams.lang"
          placeholder="请选择语言"
          @change="changeLang"
        >
          <el-option
            v-for="item in i18nOptions"
            :key="item.code"
            :label="item.name"
            :value="item.code"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary" icon="el-icon-search" size="mini"
          v-hasPermi="['app:activity:query']" @click="handleQuery"
        >搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['app:activity:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['app:activity:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['app:activity:remove']"
        >删除
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center"/>
      <el-table-column label="活动编号" align="center" prop="id"/>
      <el-table-column label="标题" align="center" prop="title" :show-overflow-tooltip="true"/>
      <el-table-column label="类型" align="center" prop="type">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.app_activity_type" :value="scope.row.type"/>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.app_activity_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" key="create_time" prop="create_time"
                       width="160"
      />
      <el-table-column
        label="操作"
        align="center"
        width="160"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['app:activity:edit']"
          >多国家维护
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-connection"
            @click="handleTranslate(scope.row)"
            v-hasPermi="['app:activity:translate']"
          >一键翻译
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['app:activity:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.page"
      :limit.sync="queryParams.page_size"
      @pagination="getList"
    />

    <!-- 添加或修改平台量化配置对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body :close-on-click-modal="false">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="应用信息" prop="app_id">
          <el-select
            v-model="form.app_id"
            placeholder="请选择应用信息"
            :disabled="form.id != undefined"
          >
            <el-option
              v-for="item in appOptions"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="类型" prop="type">
          <el-radio-group v-model="form.type">
            <el-radio
              v-for="dict in dict.type.app_activity_type"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{ dict.label }}
            </el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio
              v-for="dict in dict.type.app_activity_status"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{ dict.label }}
            </el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="显示排序" prop="order_num">
          <el-input-number v-model="form.order_num" controls-position="right" :min="0"/>
        </el-form-item>

        <el-form-item label="用户限制id集合" prop="limit_user_ids">
          <el-input v-model="form.limit_user_ids" placeholder="请输入用户限制id集合"></el-input>
        </el-form-item>

        <el-form-item label="活动赠送配置" v-if="form.type !== 5">
          <el-form-item label="赠送活期账户" prop="add_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_amount" placeholder="请输入赠送活期账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送活期冻结账户" prop="add_frozen_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_frozen_amount"
                      placeholder="请输入赠送活期冻结账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送智能账户" prop="add_ai_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_ai_amount"
                      placeholder="请输入赠送智能账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送智能冻结账户" prop="add_ai_frozen_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_ai_frozen_amount"
                      placeholder="请输入赠送智能冻结账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送虚拟智能账户" prop="add_virtual_ai_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_virtual_ai_amount"
                      placeholder="请输入赠送虚拟智能账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送抽奖次数" prop="add_lucky_draw_count" style="width:250px;float: left">
            <el-input type="number" v-model="form.add_lucky_draw_count"
                      placeholder="请输入赠送抽奖次数"></el-input>
          </el-form-item>
        </el-form-item>

        <el-form-item label="活动赠送配置" v-if="form.type === 5">
          <el-form-item label="赠送抽奖次数" prop="add_lucky_draw_count" style="width:250px;float: left">
            <el-input type="number" v-model="form.add_lucky_draw_count"
                      placeholder="请输入赠送抽奖次数"></el-input>
          </el-form-item>
        </el-form-item>

        <el-form-item label="活动充值配置" v-if="form.type === 4 || form.type === 2">
          <el-form-item label="首次充值金额" prop="first_deposit_amount" style="width:250px;float: left"
                        v-if="form.type === 2">
            <el-input type="number" v-model="form.first_deposit_amount" placeholder="请输入首次充值"></el-input>
          </el-form-item>
          <el-form-item label="充值金额" prop="deposit_amount" style="width:250px;float: left" v-if="form.type === 4">
            <el-input type="number" v-model="form.deposit_amount" placeholder="请输入充值金额"></el-input>
          </el-form-item>
          <el-form-item label="充值智能金额" prop="deposit_ai_amount" style="width:250px;float: left"
                        v-if="form.type === 4">
            <el-input type="number" v-model="form.deposit_ai_amount" placeholder="请输入充值智能金额"></el-input>
          </el-form-item>
        </el-form-item>

        <el-form-item label="团队类型" prop="team_type" v-if="form.type === 3">
          <el-radio-group v-model="form.team_type">
            <el-radio
              v-for="dict in dict.type.team_type"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{ dict.label }}
            </el-radio>
          </el-radio-group>
        </el-form-item>

        <el-form-item label="团队统计" v-if="form.type === 3 || form.type === 5">
          <el-form-item label="活动周期" prop="period">
            <el-radio-group v-model="form.period">
              <el-radio
                v-for="dict in dict.type.activity_team_period"
                :key="dict.value"
                :label="parseInt(dict.value)"
              >{{ dict.label }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="邀请数量" prop="add_team_count" style="width:250px;float: left">
            <el-input type="number" v-model="form.add_team_count" placeholder="请输入邀请数量"></el-input>
          </el-form-item>
          <el-form-item label="累计充值" prop="add_team_total_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_team_total_amount"
                      placeholder="请输入累计充值"></el-input>
          </el-form-item>
          <el-form-item label="累计首次充值" prop="add_team_total_first_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_team_total_first_amount"
                      placeholder="请输入累计首次充值"></el-input>
          </el-form-item>
        </el-form-item>

        <el-form-item label="团队条件" v-if="form.type === 3 || form.type === 5">
          <el-form-item label="有效充值" prop="add_team_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_team_amount"
                      placeholder="请输入有效充值"></el-input>
          </el-form-item>
          <el-form-item label="有效首次充值" prop="add_team_first_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_team_first_amount"
                      placeholder="请输入有效首次充值"></el-input>
          </el-form-item>
        </el-form-item>

        <el-form-item label="活动赠送会员配置" v-if="form.type === 3 && form.add_team_first_amount > 0 ">
          <el-form-item label="赠送活期账户" prop="add_customer_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_customer_amount"
                      placeholder="请输入赠送活期账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送活期冻结账户" prop="add_customer_frozen_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_customer_frozen_amount"
                      placeholder="请输入赠送活期冻结账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送智能账户" prop="add_customer_ai_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_customer_ai_amount"
                      placeholder="请输入赠送智能账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送智能冻结账户" prop="add_customer_ai_frozen_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_customer_ai_frozen_amount"
                      placeholder="请输入赠送智能冻结账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送虚拟智能账户" prop="add_customer_virtual_ai_amount" style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_customer_virtual_ai_amount"
                      placeholder="请输入赠送虚拟智能账户"></el-input>
          </el-form-item>
          <el-form-item label="赠送抽奖次数" prop="add_customer_lucky_draw_count" style="width:250px;float: left">
            <el-input type="number" v-model="form.add_customer_lucky_draw_count"
                      placeholder="请输入赠送抽奖次数"></el-input>
          </el-form-item>
        </el-form-item>

        <el-form-item label="团队奖励" v-if="form.type === 3">
          <el-form-item label="邀请会员充值返点百分比(活期账户)" prop="add_team_deposit_reward_rate"
                        style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_team_deposit_reward_rate"
                      placeholder="请输入邀请会员充值返点百分比(活期账户)"></el-input>
          </el-form-item>
          <el-form-item label="邀请会员充值返点百分比(智能账户)" prop="add_team_deposit_reward_rate_ai"
                        style="width:250px;float: left">
            <el-input type="number" step="0.01" v-model="form.add_team_deposit_reward_rate_ai"
                      placeholder="请输入邀请会员充值返点百分比(智能账户)"></el-input>
          </el-form-item>
        </el-form-item>

        <el-form-item label="标题" prop="title" style="width:500px;" v-if="form.status === 2">
          <el-input v-model="form.title" placeholder="请输入标题"></el-input>
        </el-form-item>

        <el-form-item label="标题" v-if="form.status !== 2 && form.id === undefined">
          <el-form-item label="中文" prop="title" style="width:500px;float: left">
            <el-input v-model="form.title" placeholder="请输入标题"></el-input>
          </el-form-item>
          <el-form-item :label="lang_name" prop="i18n_title" style="width:500px;float: right">
            <el-input v-model="form.i18n_title" placeholder="请输入翻译标题"></el-input>
          </el-form-item>
        </el-form-item>

        <el-form-item label="内容" v-if="form.status !=2 && form.id === undefined">
          <el-form-item label="中文" prop="content" style="width:500px;float: left">
            <TinyEditor v-model="form.content" v-if="open"></TinyEditor>
          </el-form-item>
          <el-form-item :label="lang_name" prop="i18n_content" style="width:500px;float: right">
            <TinyEditor v-model="form.i18n_content" v-if="open"></TinyEditor>
          </el-form-item>
        </el-form-item>

        <el-form-item label="中文" prop="title" v-if="form.status !=2 && form.id !== undefined && form.lang === 'zh'">
          <el-input v-model="form.title" placeholder="请输入标题"></el-input>
        </el-form-item>
        <el-form-item :label="lang_name" prop="i18n_title"
                      v-if="form.status !=2 && form.id !== undefined && form.lang !== 'zh'">
          <el-input v-model="form.i18n_title" placeholder="请输入翻译标题"></el-input>
        </el-form-item>

        <el-form-item label="中文" prop="content" v-if="form.status !=2 && form.id !== undefined && form.lang === 'zh'">
          <TinyEditor v-model="form.content" v-if="open"></TinyEditor>
        </el-form-item>
        <el-form-item :label="lang_name" prop="i18n_content"
                      v-if="form.status !=2 && form.id !== undefined && form.lang !== 'zh'">
          <TinyEditor v-model="form.i18n_content" v-if="open"></TinyEditor>
        </el-form-item>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  addAppActivity,
  delAppActivity,
  getAppActivity,
  listAppActivity,
  translateAppActivity,
  updateAppActivity
} from '@/api/metadata/appActivity'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import {getGroupApp} from "@/api/metadata/app";
import {getLangList, translate} from "@/api/metadata/i18n";
import form from "element-ui/packages/form";

export default {
  name: 'AppActivity',
  dicts: ['app_activity_type', 'app_activity_status', 'team_type', 'activity_team_period'],
  components: {Treeselect},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 平台量化表格数据
      dataList: null,
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 应用信息
      appOptions: [],
      // 语言
      i18nOptions: [],
      lang_name: '英语',
      loadingInstance: null,
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {
        page: 1,
        page_size: 10,
        app_id: undefined,
        type: undefined,
        title: undefined,
        lang: 'en'
      },
      // 表单校验
      rules: {
        app_id: [
          {required: true, message: '应用信息不能为空', trigger: 'blur'}
        ],
        title: [
          {required: true, message: '标题不能为空', trigger: 'blur'}
        ],
        content: [
          {required: true, message: '内容不能为空', trigger: 'blur'}
        ],
        i18n_title: [
          {required: true, message: '翻译标题不能为空', trigger: 'blur'}
        ],
        i18n_content: [
          {required: true, message: '翻译内容不能为空', trigger: 'blur'}
        ],
        type: [
          {required: true, message: '类型不能为空', trigger: 'blur'}
        ],
        status: [
          {required: true, message: '状态不能为空', trigger: 'blur'}
        ],
        lang: [
          {required: true, message: '语言不能为空', trigger: 'blur'}
        ],
        order_num: [
          {required: true, message: '显示排序不能为空', trigger: 'blur'}
        ],
        add_amount: [
          {required: true, message: '赠送活期账户不能为空', trigger: 'blur'}
        ],
        add_frozen_amount: [
          {required: true, message: '赠送活期冻结账户不能为空', trigger: 'blur'}
        ],
        add_ai_amount: [
          {required: true, message: '赠送智能账户不能为空', trigger: 'blur'}
        ],
        add_ai_frozen_amount: [
          {required: true, message: '赠送智能冻结账户不能为空', trigger: 'blur'}
        ],
        add_virtual_ai_amount: [
          {required: true, message: '赠送虚拟智能账户不能为空', trigger: 'blur'}
        ],
        add_lucky_draw_count: [
          {required: true, message: '赠送抽奖次数不能为空', trigger: 'blur'}
        ],
        add_customer_amount: [
          {required: true, message: '赠送会员活期账户不能为空', trigger: 'blur'}
        ],
        add_customer_frozen_amount: [
          {required: true, message: '赠送会员活期冻结账户不能为空', trigger: 'blur'}
        ],
        add_customer_ai_amount: [
          {required: true, message: '赠送会员智能账户不能为空', trigger: 'blur'}
        ],
        add_customer_ai_frozen_amount: [
          {required: true, message: '赠送会员智能冻结账户不能为空', trigger: 'blur'}
        ],
        add_customer_virtual_ai_amount: [
          {required: true, message: '赠送会员虚拟智能账户不能为空', trigger: 'blur'}
        ],
        add_customer_lucky_draw_count: [
          {required: true, message: '赠送会员抽奖次数不能为空', trigger: 'blur'}
        ],
        first_deposit_amount: [
          {required: true, message: '首次充值金额不能为空', trigger: 'blur'}
        ],
        deposit_amount: [
          {required: true, message: '充值金额不能为空', trigger: 'blur'}
        ],
        deposit_ai_amount: [
          {required: true, message: '充值智能金额不能为空', trigger: 'blur'}
        ],
        period: [
          {required: true, message: '周期不能为空', trigger: 'blur'}
        ],
        add_team_count: [
          {required: true, message: '邀请数量不能为空', trigger: 'blur'}
        ],
        add_team_amount: [
          {required: true, message: '有效充值不能为空', trigger: 'blur'}
        ],
        add_team_total_amount: [
          {required: true, message: '累计充值不能为空', trigger: 'blur'}
        ],
        add_team_first_amount: [
          {required: true, message: '有效首次充值不能为空', trigger: 'blur'}
        ],
        add_team_total_first_amount: [
          {required: true, message: '累计首次充值不能为空', trigger: 'blur'}
        ],
        team_type: [
          {required: true, message: '团队类型不能为空', trigger: 'blur'}
        ],
        add_team_deposit_reward_rate: [
          {required: true, message: '邀请会员充值返点百分比(活期账户)不能为空', trigger: 'blur'}
        ],
        add_team_deposit_reward_rate_ai: [
          {required: true, message: '邀请会员充值返点百分比(智能账户)不能为空', trigger: 'blur'}
        ],
      }
    }
  },
  created() {
    this.getGroupApp()
    this.getLangList()
  },
  methods: {
    translate() {
      if (this.form.title !== undefined && this.form.title !== '') {
        translate({lang: this.form.lang, description: this.form.title}).then(response => {
          this.$set(this.form, 'i18n_title', response.data.i18n_description)
        })
      }
    },
    changeLang() {
      this.form.lang = this.queryParams.lang
    },
    getLangList() {
      getLangList().then(response => {
        this.i18nOptions = response.data
      })
    },
    getGroupApp() {
      getGroupApp().then(response => {
        this.appOptions = response.data
        this.queryParams.app_id = response.data[0].id
        this.getList()
      })
    },
    /** 查询平台量化列表 */
    getList() {
      this.loading = true
      listAppActivity(this.queryParams).then(response => {
          this.dataList = response.data
          this.total = response.total
          this.loading = false
        }
      )
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
      this.getList()
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        app_id: undefined,
        title: undefined,
        i18n_title: undefined,
        content: undefined,
        i18n_content: undefined,
        order_num: 0,
        type: 1,
        status: 1,
        lang: 'en',
        add_amount: 0.00,
        add_frozen_amount: 0.00,
        add_ai_amount: 0.00,
        add_ai_frozen_amount: 0.00,
        add_virtual_ai_amount: 0.00,
        add_customer_amount: 0.00,
        add_customer_frozen_amount: 0.00,
        add_customer_ai_amount: 0.00,
        add_customer_ai_frozen_amount: 0.00,
        add_customer_virtual_ai_amount: 0.00,
        add_customer_lucky_draw_count: 0,
        first_deposit_amount: 0.00,
        deposit_amount: 0.00,
        deposit_ai_amount: 0.00,
        period: 0,
        add_team_count: 0,
        add_team_amount: 0.00,
        add_team_first_amount: 0.00,
        add_team_total_amount: 0.00,
        add_team_total_first_amount: 0.00,
        add_team_deposit_reward_rate: 0.00,
        add_team_deposit_reward_rate_ai: 0.00,
        team_type: 0,
        limit_user_ids: undefined,
      }
      this.resetClearForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.form.lang = 'en'
      this.form.app_id = this.queryParams.app_id
      this.getLangName(this.form.lang)
      this.open = true
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      this.form.lang = this.queryParams.lang
      this.form.app_id = this.queryParams.app_id
      const lang = this.form.lang
      getAppActivity(id, lang).then(response => {
        this.form = response.data;
        this.form.lang = lang
        this.getLangName(this.form.lang)
        this.open = true;
        this.title = "修改参数";
      })
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs['form'].validate(valid => {
        if (valid) {
          let step = async () => {
            if (this.form.id != undefined) {
              updateAppActivity(this.form).then(response => {
                this.$modal.msgSuccess('修改成功')
                this.open = false
                this.getList()
              })
            } else {
              addAppActivity(this.form).then(response => {
                this.$modal.msgSuccess('新增成功')
                this.open = false
                this.getList()
              })
            }
          }
          step()
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除编号为"' + ids + '"的数据项？').then(function () {
        return delAppActivity(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },
    getLangName(lang) {
      this.i18nOptions.filter((item) => {
        if (item.code == lang) {
          this.lang_name = item.name
        }
      })
    },
    /** 一键翻译按钮操作 */
    handleTranslate(row) {
      const id = row.id
      this.$modal.confirm('是否确认一键翻译编号为"' + id + '"的数据项？').then(function () {
        return translateAppActivity(id)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('翻译成功')
      }).catch(() => {
      })
    }
  }
}
</script>
